package com.jnu.hc.jnuhcdoccms.service;

import com.jnu.hc.jnuhcdoccms.dto.ResponseObject;
import com.jnu.hc.jnuhcdoccms.exception.HcAPPException;
import com.jnu.hc.jnuhcdoccms.exception.HcAppExceptionEnum;
import com.jnu.hc.jnuhcusercms.domain.Doctor;
import com.jnu.hc.jnuhcusercms.mapper.DoctorMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class DoctorServiceImpl implements DoctorService {
    @Autowired
    DoctorMapper doctorMapper;
    @Override
    public ResponseObject doctorLogin(Doctor doctor){
        Doctor result= doctorMapper.selectByDocCode(doctor.getDocCode());
        if(result==null){
            System.out.println("没有找到该医生");
            throw  new HcAPPException(HcAppExceptionEnum.MOBILE_NOT_REGISTERED.getCode(),HcAppExceptionEnum.MOBILE_NOT_REGISTERED.getMessage());
        }
        else {
            if(doctor.getPassword().equals(result.getPassword())){
                result.setPassword(null);
                return new ResponseObject(ResponseObject.SUCCESS_STATUS,ResponseObject.SUCCESS_DESC,result);
            }
            return new ResponseObject(4002,"账号或密码错误");

        }
    }
}
